//
//  UserDefinedCellForSubView3OfWaringInformation.m
//  HondaPro_2
//
//  Created by Eric on 13-6-14.
//  Copyright (c) 2013年 glendale. All rights reserved.
//

#import "UserDefinedCellForSubView3OfWaringInformation.h"

@interface UserDefinedCellForSubView3OfWaringInformation ()

//创建自定义labels
-(void)initLabelsOnCell;

@end

@implementation UserDefinedCellForSubView3OfWaringInformation

@synthesize dicForLabelsOnCell = _dicForLabelsOnCell;
@synthesize arrForKeys = _arrForKeys;

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        // Initialization code
        
        [self initLabelsOnCell];
        
        self.selectionStyle = UITableViewCellSelectionStyleNone;
    }
    return self;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

#pragma mark - 创建 labels

-(void)initLabelsOnCell
{
    self.dicForLabelsOnCell = [NSMutableDictionary dictionaryWithCapacity:3];
    
    self.arrForKeys = [NSArray arrayWithObjects:
                       MM_WARING_INFORMATION_CHECK_RECORDS_HISTORY_CUSTOMER_DESCRIPTION_KEY_STR_,
                       MM_WARING_INFORMATION_CHECK_RECORDS_HISTORY_COMING_DATE_KEY_STR_,
                       MM_WARING_INFORMATION_CHECK_RECORDS_HISTORY_DELIVERY_DATE_KEY_STR_,
                       MM_WARING_INFORMATION_CHECK_RECORDS_HISTORY_COMING_MILEAGE_KEY_STR_,
                       MM_WARING_INFORMATION_CHECK_RECORDS_HISTORY_SHOP_ID_KEY_STR_,
                       MM_WARING_INFORMATION_CHECK_RECORDS_HISTORY_JOB_SHEET_ID_KEY_STR_,
                       MM_WARING_INFORMATION_CHECK_RECORDS_HISTORY_CHECK_RESULTS_KEY_STR_, nil];
    
    NSDictionary *dicForLabelsOnCellRect =
    [NSDictionary dictionaryWithObjectsAndKeys:
     [NSValue valueWithCGRect:CGRectMake(0, 0, 180, 50)],MM_WARING_INFORMATION_CHECK_RECORDS_HISTORY_CUSTOMER_DESCRIPTION_KEY_STR_,
     [NSValue valueWithCGRect:CGRectMake(181, 0, 120, 50)],MM_WARING_INFORMATION_CHECK_RECORDS_HISTORY_COMING_DATE_KEY_STR_,
     [NSValue valueWithCGRect:CGRectMake(302, 0, 120, 50)],MM_WARING_INFORMATION_CHECK_RECORDS_HISTORY_DELIVERY_DATE_KEY_STR_,
     [NSValue valueWithCGRect:CGRectMake(423, 0, 120, 50)],MM_WARING_INFORMATION_CHECK_RECORDS_HISTORY_COMING_MILEAGE_KEY_STR_,
     [NSValue valueWithCGRect:CGRectMake(544, 0, 120, 50)],MM_WARING_INFORMATION_CHECK_RECORDS_HISTORY_SHOP_ID_KEY_STR_,
     [NSValue valueWithCGRect:CGRectMake(665, 0, 120, 50)],MM_WARING_INFORMATION_CHECK_RECORDS_HISTORY_JOB_SHEET_ID_KEY_STR_,
     [NSValue valueWithCGRect:CGRectMake(786, 0, 136, 50)],MM_WARING_INFORMATION_CHECK_RECORDS_HISTORY_CHECK_RESULTS_KEY_STR_, nil];
    
    //给字典中 添加 11 个label，因为cell上有 11 项要显示
    
    for (int i = 0; i<[_arrForKeys count]; i++)
    {
        UILabel *lbl = [[UILabel alloc] initWithFrame:[[dicForLabelsOnCellRect objectForKey:[_arrForKeys objectAtIndex:i]] CGRectValue]];
        lbl.backgroundColor = [UIColor clearColor];
        lbl.font = [UIFont systemFontOfSize:13];
        lbl.numberOfLines = 2;
        lbl.textColor = [UIColor grayColor];
        [self.contentView addSubview:lbl];
        [self.dicForLabelsOnCell setValue:lbl forKey:[_arrForKeys objectAtIndex:i]];
    }
}

@end
